﻿using System;
using System.Collections.Generic;
using System.Text;
using StockTrader.BusinessService.DataContract;
using StockTrader.BusinessService.DataContract.Mortgate;

namespace StockTrader.DAL.IDAL.LoanMonitor
{
    public interface IMortgage
    {
        void BeginADOTransaction();
        void RollBackTransaction();
        void CommitADOTransaction();
        void Open(string connString);
        void Close();

        #region Loan rate
        void InportLoadRate(LoanRateData item);
        decimal getLoanRate(DateTime date, string symbol);
        void DeleteLoanRate(DateTime date);
        #endregion

        void InsertMortgageTrans(string accountno, string contractno, DateTime date, string code, int type, decimal credit, decimal debit);
        void DeleteMortgageTransByContractNo(string contractno);
        List<MortgageTrans> getMortgageTransByCode(string contractno);
        decimal getBlockingQttyByCodeAndContract(string AccountNo, string code, string contractno);
        decimal getBlockingQttyByCode(string AccountNo, string code);
        List<MortgageTrans> searchMortgageTrans(string code, string accountno, string contractno,
                                                DateTime from, DateTime to, int type,
                                                decimal lowDebit, decimal highDebit,
                                                decimal lowCredit, decimal highCredit);


        void InsertCustomer(string Name, string Gender, string AccountNo, string IdcardNo, DateTime IdcardDate, string IdcardIssue, string PhoneMobile, string PhoneFix, string Email, string AddressContact, string AddressResident);
        List<AccountData> getCustomers();
        string getCustomerByAccountNo(string AccountNo);
        AccountData getCustomerByID(string id);
        void DeleteCustomerById(string CustomerID);

        int InsertFee(DateTime from, DateTime to, string Name, int type, decimal value, string customerid, string contractno, string accountno);
        FeeData getFeeByCode(string ID);
        FeeData getFeeByCodeAndDate(string Name, DateTime date);
        FeeData getFee(int type, string customerid, string contractno, string accountno);

        void InsertContract(string contractno, string customerid, DateTime start, DateTime end, decimal fee, decimal penaltyfee, decimal processfee, int contracttype, string status, decimal contractvalue, string AccountNo, string original);
        ContractData getContractByNo(string contractno);
        List<ContractData> getContractByAccountNo(string accountno);
        List<ContractData> getcontractByCustomerId(string customerid);
        List<ContractData> getContractByStartDate(DateTime from, DateTime to);
        List<ContractData> getContractByEndDate(DateTime from, DateTime to);
        List<ContractData> getContractByValue(decimal from, decimal to);
        List<ContractData> searchContract(string contractno, string customerid, 
                                            DateTime from, DateTime to, 
                                            decimal lowvalue, decimal highvalue,
                                            int contracttype, string status, string AccountNo,
                                            string originalContract);
        

        void InsertCustomerAccount(string customerId, string accounts);
        List<string> getCustomerAccounts(string customerId);
        void deleteCustomerAccount(string customerId);
        
        decimal GetAccumulateLoanByAccountNo(string AccountNo);
        void UpdateAccumulateLoan(string AccountNo, decimal AccuValue, DateTime LastUpdate);
    }
}
